//
//  HWpinglunHeaderView.m
//  HWanGame
//
//  Created by 陈道斌 on 2021/8/31.
//  Copyright © 2021 Chendaobin. All rights reserved.
//

#import "HWpinglunHeaderView.h"
//#import <ZLPhotoBrowser.h>

@interface HWpinglunHeaderView()<UIScrollViewDelegate>
@property(strong,nonatomic)UIImageView *headFrameImageView;
@property(strong,nonatomic)UIImageView *icoIamgeView;
@property(strong,nonatomic)GranibleLabel *biaotiLabel;
@property(strong,nonatomic)UIImageView *medalImageView;
@property(strong,nonatomic)UIImageView *vipImageView;
// @property(strong,nonatomic)NSMutableArray *storeStarsMuArr;
@property(strong,nonatomic)UILabel *leirongLabel;
@property(strong,nonatomic)UIView *storeImageView;

@property(strong,nonatomic) UIScrollView *scrollView;
@property(strong,nonatomic) NSMutableArray *colorsArr;





@end

@implementation HWpinglunHeaderView


+ (instancetype)headFooterViewWithTableview:(UITableView *)tableview {
    
    HWpinglunHeaderView *view = [tableview dequeueReusableHeaderFooterViewWithIdentifier:NSStringFromClass([HWpinglunHeaderView class])];

      if (view == nil) {
          view = [[HWpinglunHeaderView alloc]initWithReuseIdentifier:NSStringFromClass([HWpinglunHeaderView class])];
      }
      view.backgroundColor = [UIColor yellowColor];
      return view;
    
}


- (instancetype)initWithReuseIdentifier:(NSString *)reuseIdentifier {
    
    if(self = [super initWithReuseIdentifier:reuseIdentifier]){
        self.colorsArr = [NSMutableArray arrayWithCapacity:3];
        self.contentView.backgroundColor = [UIColor whiteColor];
        
        self.icoIamgeView = [[UIImageView alloc]initWithFrame:CGRectMake(15, 15, 38, 38)];
        self.icoIamgeView.layer.cornerRadius  = 19;
        self.icoIamgeView.layer.masksToBounds =YES;
        self.icoIamgeView.backgroundColor = [UIColor whiteColor];
        [self.contentView addSubview: self.icoIamgeView];
        
        self.headFrameImageView = [[UIImageView alloc]initWithFrame:CGRectMake(15, 15, 44, 44)];
        self.headFrameImageView.layer.cornerRadius  = 22;
        self.headFrameImageView.layer.masksToBounds =YES;
        self.headFrameImageView.backgroundColor = [UIColor clearColor];
        [self.contentView addSubview: self.headFrameImageView];
        
        [self.headFrameImageView mas_makeConstraints:^(MASConstraintMaker *make) {
            make.center.mas_equalTo(self.icoIamgeView);
            make.width.height.mas_equalTo(55);
        }];
        
        
//        self.biaotiLabel  = [[UILabel alloc]initWithFrame:CGRectMake( self.icoIamgeView.right+10, 15, 200, 22)];
//         self.biaotiLabel.text = @"幻想骑士团";
//        self.biaotiLabel.font = [UIFont fontWithName:@"Helvetica-Bold" size:14];
//
//         self.biaotiLabel.textColor = RGB(51, 51, 51);
//         self.biaotiLabel.textAlignment =  NSTextAlignmentLeft;
//         [self.contentView addSubview:self.biaotiLabel];
        
        
//        nameLabel = GranibleLabel()
//        nameLabel.font = .boldSystemFont(ofSize: 14)
//        nameLabel.isUserInteractionEnabled = true
//        contentView.addSubview(nameLabel)
        self.biaotiLabel = [[GranibleLabel alloc] init];
        self.biaotiLabel.frame = CGRectMake( self.icoIamgeView.right+10, 15, 200, 22);
        self.biaotiLabel.text = @"";
        self.biaotiLabel.font = [UIFont fontWithName:@"Helvetica-Bold" size:14];
        self.biaotiLabel.textAlignment = NSTextAlignmentLeft;
        [self.contentView addSubview:self.biaotiLabel];
        [self.biaotiLabel mas_makeConstraints:^(MASConstraintMaker *make) {
                    make.left.mas_equalTo(self.icoIamgeView.mas_right).offset(10);
                    make.top.mas_equalTo(15);
        }];
        
        self.medalImageView = [[UIImageView alloc] init];
        [self.contentView addSubview:self.medalImageView];
        
        [self.medalImageView mas_makeConstraints:^(MASConstraintMaker *make) {
            make.left.mas_equalTo(self.biaotiLabel.mas_right).offset(6);
            make.width.height.mas_equalTo(18);
            make.centerY.mas_equalTo(self.biaotiLabel);
        }];
        
        self.vipImageView = [[UIImageView alloc] init];
        [self.contentView addSubview:self.vipImageView];
        [self.vipImageView mas_makeConstraints:^(MASConstraintMaker *make) {
            make.left.mas_equalTo(self.medalImageView.mas_right).offset(6);
            make.width.height.mas_equalTo(18);
            make.centerY.mas_equalTo(self.biaotiLabel);
        }];
        self.storeStarsMuArr = [[NSMutableArray alloc]init];
    
        for (int i = 0 ; i < 5 ; i++) {
            UIImageView *imageView = [[UIImageView alloc]initWithFrame:CGRectMake(self.icoIamgeView.right+10+i*10+i*5, self.biaotiLabel.bottom+5, 10, 10)];
            imageView.image = [UIImage imageNamed:@"xingxingicopingfen"];
            imageView.hidden = NO;
            [self.contentView addSubview:imageView];
            [self.storeStarsMuArr addObject:imageView];
            
            
        }
        
        NSString  *str1  =  @"eee";
        
        
        CGSize   size1 =  [WMUtil strName:str1 fontSize:[UIFont systemFontOfSize:14]  boundingRectWithSize:CGSizeMake(kScreenW-60-20, 2000)];
        CGSize   size2 =    [WMUtil sizeWithFont1:[UIFont systemFontOfSize:14] maxSize:CGSizeMake(kScreenW-60-15, 2000) string:str1];
    
        self.leirongLabel  = [[UILabel alloc]initWithFrame:CGRectMake( 60, 38+15+5, kScreenW-60-15 , size2.height)];
         self.leirongLabel.text = str1;
         self.leirongLabel.font = [UIFont systemFontOfSize:14];
         self.leirongLabel.textColor = RGB(51, 51, 51);
       //  self.nameNiChengLabel.backgroundColor = [UIColor redColor];
         self.leirongLabel.textAlignment =  NSTextAlignmentLeft;
     //    self.jianjienLabel.layer.borderWidth = 1;
     //    self.jianjienLabel.layer.borderColor = RGB(38, 154, 255).CGColor;
     //    self.jianjienLabel.layer.cornerRadius = 3;
     //    self.jianjienLabel.layer.masksToBounds = YES;
         self.leirongLabel.numberOfLines = 0;
         self.leirongLabel.backgroundColor = [UIColor whiteColor];
         [self.contentView addSubview:self.leirongLabel];
        
       
        
        self.storeImageView =  [[UIView alloc]initWithFrame:CGRectMake(60, self.leirongLabel.bottom+10 ,  kScreenW-60-15 , 85*2+1*10 )];
        self.storeImageView.backgroundColor = [UIColor whiteColor];
        [self.contentView addSubview:self.storeImageView];
        
        
        UITapGestureRecognizer *tap1  = [[UITapGestureRecognizer alloc]initWithTarget:self action:@selector(xiangqingTap)];
        [self.contentView   addGestureRecognizer:tap1];
        
        
        UILongPressGestureRecognizer *longPress = [[UILongPressGestureRecognizer alloc]initWithTarget:self action:@selector(longPressAction:)];//初始化一个长按手势
        [longPress setMinimumPressDuration:1];//设置按多久之后触发事件
        [self.contentView addGestureRecognizer:longPress];//把长按手势添加给按钮
         
        
        
        
        
        
        

    }
    
    
    return  self;
    
    
}

//当前控件的frame发生改变的时候会调用这个方法

- (void)layoutSubviews{
    [super layoutSubviews];
    
    
    
  
}

-(void)setModel:(HWpinglunFrame *)model {
    
    
    _model = model ;
    HWpinglunModel *data=   model.datamodel;
    [self.icoIamgeView sd_setImageWithURL:[NSURL URLWithString:data.touxiang] placeholderImage:nil];
    [self.headFrameImageView sd_setImageWithURL:[NSURL URLWithString:data.head_frame] placeholderImage:nil];
    [self.medalImageView sd_setImageWithURL:[NSURL URLWithString:data.medal] placeholderImage:nil];
    [self.vipImageView sd_setImageWithURL:[NSURL URLWithString:data.huiyuan_img] placeholderImage:nil];
    self.biaotiLabel.text = data.user_name;
    [self.colorsArr removeAllObjects];
    for (int i = 0; i<data.color.count; i++) {
        [self.colorsArr addObject:[UIColor colorWithHexStringWithHexString:data.color[i]]];
    }
    if (data.color.count == 1) {
        [self.colorsArr addObject:[UIColor colorWithHexStringWithHexString:data.color[0]]];
        [self.colorsArr addObject:[UIColor colorWithHexStringWithHexString:data.color[0]]];
    }
    self.biaotiLabel.colors = self.colorsArr;
    CGSize   size2 =    [WMUtil sizeWithFont1:[UIFont systemFontOfSize:14] maxSize:CGSizeMake(kScreenW-60-15, 2000) string:data.content];
    self.leirongLabel.frame = CGRectMake( 60, 38+15+5, kScreenW-60-15 , size2.height) ;
    self.leirongLabel.text =  data.content;
    
    [self.storeImageView.subviews makeObjectsPerformSelector:@selector(removeFromSuperview)];

    
    
    
    self.storeImageView.frame =  CGRectMake(60, self.leirongLabel.bottom+10 ,  kScreenW-60-15 ,model.icoViewgaoduo);
    
    
    int xingge =  [data.point intValue];
    for (int i = 0; i < 5 ; i++) {
        UIImageView *imageview =  self.storeStarsMuArr[i];
        if (i < xingge) {
          
            imageview.hidden = NO;
             
        } else {
            
            imageview.hidden = YES;
        }
      
    }
     CGFloat kuandu =  (kScreenW-60-15-20)/3;

     for (int i = 0; i < data.images.count; i++) {
            
            NSInteger lin = i/3;
            NSInteger lie = i%3;
            UIImageView *imageview = [[UIImageView alloc] initWithFrame:CGRectMake(lie*kuandu+lie*10, lin*85+lin*10, kuandu, 85)];
            [imageview sd_setImageWithURL:[NSURL URLWithString:data.images[i]] placeholderImage:nil];
            imageview.userInteractionEnabled = YES;
            UITapGestureRecognizer *tupiantap = [[UITapGestureRecognizer alloc]initWithTarget:self action:@selector(tupianTap:)];
             [imageview addGestureRecognizer:tupiantap];
              imageview.tag = i;
            [self.storeImageView addSubview:imageview];

    }
    
    
    
//    UITapGestureRecognizer *tap1  = [[UITapGestureRecognizer alloc]initWithTarget:self action:@selector(xiangqingTap)];
//    [self.contentView   addGestureRecognizer:tap1];
//
//
    
    
    
    
}


-(void)longPressAction:(UILongPressGestureRecognizer*)sender{
 //    UIGestureRecognizerStatePossible,按钮state的各种枚举值
 //    UIGestureRecognizerStateBegan,
 //    UIGestureRecognizerStateChanged,
 //    UIGestureRecognizerStateEnded,
 //    UIGestureRecognizerStateCancelled,
 //    UIGestureRecognizerStateFailed,
 //    UIGestureRecognizerStateRecognized = UIGestureRecognizerStateEnded
    if (sender.state == UIGestureRecognizerStateBegan) {
         //  myBtn.backgroundColor = [UIColor greenColor];//当状态为Began时，触发事件（修改btn的背景色）
        
        NSLog(@"1234567");
        
        if ([self.delegate respondsToSelector:@selector(HWpinglunheadViewDelegate:)]) {
            [self.delegate HWpinglunheadViewDelegate:self.model];
        }
        
        
    } else if (sender.state == UIGestureRecognizerStateEnded) {
        
        NSLog(@"diiodioiodiho");
        
        
        
    }
    
    
    


}




- (void)xiangqingTap {
    
    
    if ([self.delegate respondsToSelector:@selector(HWpinglunHeaderView:)]) {
        [self.delegate HWpinglunHeaderView:self.model];
    }
    
  //   [self.delegate HWpinglunHeaderView:self.model];
    
    
    if ([self.delegate respondsToSelector:@selector(HWpinglunHeaderViewSection:)]) {
        [self.delegate HWpinglunHeaderViewSection:self.section];
    }
    
    
    
}


-(void)setXiangqingModel:(HWpinglunFrame *)xiangqingModel {
    
    _xiangqingModel = xiangqingModel;
    
    
    
    HWpinglunModel *data=   xiangqingModel.datamodel;
    [self.icoIamgeView sd_setImageWithURL:[NSURL URLWithString:data.touxiang] placeholderImage:nil];
    
    self.biaotiLabel.text = data.user_name;
    
   //   WMUtil  attributedStringWithText

    CGSize   size2 =    [WMUtil sizeWithFont1:[UIFont systemFontOfSize:14] maxSize:CGSizeMake(kScreenW-60-15, 2000) string:data.content];
    self.leirongLabel.frame = CGRectMake( 60, 38+15+5, kScreenW-60-15 , size2.height) ;
    self.leirongLabel.text =  data.content;
    
    
    if (data.beihuifu_user_name == nil  ) {
        self.leirongLabel.text = data.content;
    } else {
        
        NSString *str = [NSString stringWithFormat:@"回复@%@:%@",data.beihuifu_user_name,data.content];
        NSString  *str1  = [NSString stringWithFormat:@"@%@:",data.beihuifu_user_name];
        self.leirongLabel.attributedText = [ WMUtil  attributedStringWithText:str withRangText:str1 withColor:RGB(247, 124, 47) withFont:[UIFont systemFontOfSize:14]];
        
    }

    [self.storeImageView.subviews makeObjectsPerformSelector:@selector(removeFromSuperview)];
    self.storeImageView.frame =  CGRectMake(60, self.leirongLabel.bottom+10 ,  kScreenW-60-15 ,xiangqingModel.icoViewgaoduo);
    int xingge =  [data.point intValue]/2;
    for (int i = 0; i < 5 ; i++) {
        UIImageView *imageview =  self.storeStarsMuArr[i];
        if (i < xingge) {
          
            imageview.hidden = NO;
             
        } else {
            
            imageview.hidden = YES;
        }
      
    }
     CGFloat kuandu =  (kScreenW-60-15-20)/3;

     for (int i = 0; i < data.images.count; i++) {
            
            NSInteger lin = i/3;
            NSInteger lie = i%3;
            UIImageView *imageview = [[UIImageView alloc] initWithFrame:CGRectMake(lie*kuandu+lie*10, lin*85+lin*10, kuandu, 85)];
            [imageview sd_setImageWithURL:[NSURL URLWithString:data.images[i]] placeholderImage:nil];
         
          imageview.userInteractionEnabled = YES;
          UITapGestureRecognizer *tupiantap = [[UITapGestureRecognizer alloc]initWithTarget:self action:@selector(tupianTap:)];
          [imageview addGestureRecognizer:tupiantap];
           imageview.tag = i;
         
         
            [self.storeImageView addSubview:imageview];

    }
    
    
    
    
}


//-(CGSize)sizeWithFont:(UIFont *)font maxSize:(CGSize)maxSize string:(NSString *)string{
//
//      NSDictionary *attrs = @{NSFontAttributeName:font};
//
//      return [string boundingRectWithSize:maxSize options:NSStringDrawingUsesLineFragmentOrigin attributes:attrs context:nil].size;
//
//}



- (void)tupianTap:(UITapGestureRecognizer *)sender {
    NSInteger tag =  sender.view.tag;
    
    UIScrollView *bgView = [[UIScrollView alloc] init];
    bgView.frame = [UIScreen mainScreen].bounds;
    bgView.backgroundColor = [UIColor blackColor];
    UITapGestureRecognizer *tapBg = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(tapBgView:)];
    [bgView addGestureRecognizer:tapBg];
    bgView.pagingEnabled = YES;
    self.scrollView = bgView;
    [[[UIApplication sharedApplication] keyWindow] addSubview:bgView];
    
    self.scrollView.delegate = self;
    NSArray *imagesarr =  self.model.datamodel.images;
    [self.scrollView setContentSize:CGSizeMake( imagesarr.count*SCREEN_WIDTH, SCREEN_HEIGHT)];
    
      self.scrollView.contentOffset = CGPointMake(tag * SCREEN_WIDTH, 0);
    
    
       for (int i = 0 ; i <  imagesarr.count; i ++) {
           
//           NSLog(@"youzhima%lu", (unsigned long)self.entity.imgs.count);
          


           UIImageView *imageView = [[UIImageView alloc] init];
           // imageView.image =  [UIImage imageNamed:self.entity.imgs[i]];
           
           // [imageView sd_setImageWithURL:[NSURL URLWithString:self.entity.imgs[i]] placeholderImage:[UIImage imageNamed:@""]];
           // imageView.image = [UIImage imageNamed:@"1"];
           
           imageView.tag = i+100;
           
           // imageView.frame = [bgView convertRect:picView.frame fromView:self.view];
           [bgView addSubview:imageView];
           
           //        CGRect frame = imageView.frame;
           //        frame.size.width = bgView.frame.size.width;
           //        frame.size.height = frame.size.width * (imageView.image.size.height / imageView.image.size.width);
           //        frame.origin.x = i *  bgView.frame.size.width;
           //        frame.origin.y = (bgView.frame.size.height - frame.size.height) * 0.5;
           //        imageView.frame = frame;
           
           
           if (i == tag) {
          
               
                [imageView  sd_setImageWithURL:[NSURL URLWithString:imagesarr[i]] completed:^(UIImage * _Nullable image, NSError * _Nullable error, SDImageCacheType cacheType, NSURL * _Nullable imageURL) {

                       CGRect frame = imageView.frame;
                       frame.size.width = self.scrollView.frame.size.width;
                       frame.size.height = frame.size.width * (imageView.image.size.height / imageView.image.size.width);
                       frame.origin.x = i *  self.scrollView.frame.size.width;
                       frame.origin.y = (self.scrollView.frame.size.height - frame.size.height) * 0.5;
                       imageView.frame = frame;
                       imageView.image = image;

               //        self.lastImageView =  imagView;
               //
               //        self.originalFrame = imagView.frame;


                   }];


               continue;
           }
           
           
           
       }
    
   
    
    
}

- (void)scrollViewDidEndDecelerating:(UIScrollView *)scrollView {
    
    NSInteger leftI = scrollView.contentOffset.x / SCREEN_WIDTH;
    UIImageView *imagView = [self.scrollView viewWithTag:leftI+100];
    //  [imagView sd_setImageWithURL:[NSURL URLWithString:self.entity.imgs[i]] placeholderImage:[UIImage imageNamed:@""]];
    NSArray *imagesarr =   self.model.datamodel.images;
    [imagView  sd_setImageWithURL:[NSURL URLWithString:imagesarr[leftI]] completed:^(UIImage * _Nullable image, NSError * _Nullable error, SDImageCacheType cacheType, NSURL * _Nullable imageURL) {
        
        CGRect frame = imagView.frame;
        frame.size.width = self.scrollView.frame.size.width;
        frame.size.height = frame.size.width * (imagView.image.size.height / imagView.image.size.width);
        frame.origin.x = leftI *  self.scrollView.frame.size.width;
        frame.origin.y = (self.scrollView.frame.size.height - frame.size.height) * 0.5;
        imagView.frame = frame;
        imagView.image = image;
        
//        self.lastImageView =  imagView;
//
//        self.originalFrame = imagView.frame;
        
        
    }];
    
    
    
    
    
    
    
    
    
    
    
    
}










-(void)tapBgView:(UITapGestureRecognizer *)tapBgRecognizer
{
    //    self.scrollView.contentOffset = CGPointZero;
    //    [UIView animateWithDuration:0.5 animations:^{
    //        self.lastImageView.frame = self.originalFrame;
    //        tapBgRecognizer.view.backgroundColor = [UIColor clearColor];
    //    } completion:^(BOOL finished) {
    //        [tapBgRecognizer.view removeFromSuperview];
    //        self.scrollView = nil;
    //        self.lastImageView = nil;
    //    }];
    
    self.scrollView.contentOffset = CGPointZero;
    [self.scrollView removeFromSuperview];
 
}




//- (ZLPhotoActionSheet *)getPas
//{
//    ZLPhotoActionSheet *actionSheet = [[ZLPhotoActionSheet alloc] init];
//
//#pragma mark - 参数配置 optional，可直接使用 defaultPhotoConfiguration
//
//    //以下参数为自定义参数，均可不设置，有默认值
////    actionSheet.configuration.sortAscending = self.sortSegment.selectedSegmentIndex==0;
////    actionSheet.configuration.allowSelectImage = self.selImageSwitch.isOn;
////    actionSheet.configuration.allowSelectGif = self.selGifSwitch.isOn;
////    actionSheet.configuration.allowSelectVideo = self.selVideoSwitch.isOn;
////    actionSheet.configuration.allowSelectLivePhoto = self.selLivePhotoSwitch.isOn;
////    actionSheet.configuration.allowForceTouch = self.allowForceTouchSwitch.isOn;
////    actionSheet.configuration.allowEditImage = self.allowEditSwitch.isOn;
////    actionSheet.configuration.allowEditVideo = self.allowEditVideoSwitch.isOn;
////    actionSheet.configuration.allowSlideSelect = self.allowSlideSelectSwitch.isOn;
////    actionSheet.configuration.mutuallyExclusiveSelectInMix = !self.mixSelectSwitch.isOn;
////    actionSheet.configuration.allowDragSelect = self.allowDragSelectSwitch.isOn;
//    //设置相册内部显示拍照按钮
//   //  actionSheet.configuration.allowTakePhotoInLibrary = self.takePhotoInLibrarySwitch.isOn;
//    //设置在内部拍照按钮上实时显示相机俘获画面
//  //  actionSheet.configuration.showCaptureImageOnTakePhotoBtn = self.showCaptureImageSwitch.isOn;
//    //设置照片最大预览数
//  //   actionSheet.configuration.maxPreviewCount = self.previewTextField.text.integerValue;
//    //设置照片最大选择数
//  //  actionSheet.configuration.maxSelectCount = 9;
//    //设置允许选择的视频最大时长
//  //   actionSheet.configuration.maxVideoDuration = self.maxVideoDurationTextField.text.integerValue;
//    //设置照片cell弧度
//   //  actionSheet.configuration.cellCornerRadio = self.cornerRadioTextField.text.floatValue;
//    //单选模式是否显示选择按钮
//    //    actionSheet.configuration.showSelectBtn = YES;
//    //是否在选择图片后直接进入编辑界面
//  //   actionSheet.configuration.editAfterSelectThumbnailImage = self.editAfterSelectImageSwitch.isOn;
//    //是否保存编辑后的图片
//    //    actionSheet.configuration.saveNewImageAfterEdit = NO;
//    //设置编辑比例
//    //    actionSheet.configuration.clipRatios = @[GetClipRatio(7, 1)];
//    //是否在已选择照片上显示遮罩层
//   //  actionSheet.configuration.showSelectedMask = self.maskSwitch.isOn;
////    actionSheet.configuration.showSelectedIndex = NO;
//    //颜色，状态栏样式
//    //    actionSheet.configuration.previewTextColor = [UIColor brownColor];
//    //    actionSheet.configuration.selectedMaskColor = [UIColor purpleColor];
//    //    actionSheet.configuration.navBarColor = [UIColor orangeColor];
//    //    actionSheet.configuration.navTitleColor = [UIColor blackColor];
//    //    actionSheet.configuration.bottomBtnsNormalTitleColor = kRGB(80, 160, 100);
//    //    actionSheet.configuration.bottomBtnsDisableBgColor = kRGB(190, 30, 90);
//    //    actionSheet.configuration.bottomViewBgColor = [UIColor blackColor];
//    //    actionSheet.configuration.statusBarStyle = UIStatusBarStyleDefault;
//    //是否允许框架解析图片
// //    actionSheet.configuration.shouldAnialysisAsset = self.allowAnialysisAssetSwitch.isOn;
//    //框架语言
//   //  actionSheet.configuration.languageType = self.languageSegment.selectedSegmentIndex;
//    //自定义多语言
//    //    actionSheet.configuration.customLanguageKeyValue = @{@"ZLPhotoBrowserCameraText": @"没错，我就是一个相机"};
//    //自定义图片
//    //    actionSheet.configuration.customImageNames = @[@"zl_navBack"];
//
//    //是否使用系统相机
//    //    actionSheet.configuration.useSystemCamera = YES;
//    //    actionSheet.configuration.sessionPreset = ZLCaptureSessionPreset1920x1080;
//    //    actionSheet.configuration.exportVideoType = ZLExportVideoTypeMp4;
//    //    actionSheet.configuration.allowRecordVideo = NO;
//    //    actionSheet.configuration.maxRecordDuration = 5;
//#pragma mark - required
//    //如果调用的方法没有传sender，则该属性必须提前赋值
//    actionSheet.sender =  [HWViewUtils getCurrentVC];
//    //记录上次选择的图片
//  //   actionSheet.arrSelectedAssets = self.rememberLastSelSwitch.isOn&&self.maxSelCountTextField.text.integerValue>1 ? self.lastSelectAssets : nil;
//
//    @zl_weakify(self);
//    [actionSheet setSelectImageBlock:^(NSArray<UIImage *> * _Nonnull images, NSArray<PHAsset *> * _Nonnull assets, BOOL isOriginal) {
//        @zl_strongify(self);
////        self.arrDataSources = images;
////        self.isOriginal = isOriginal;
////        self.lastSelectAssets = assets.mutableCopy;
////        self.lastSelectPhotos = images.mutableCopy;
////        [self.collectionView reloadData];
//        NSLog(@"image:%@", images);
//        //解析图片
////        if (!self.allowAnialysisAssetSwitch.isOn) {
////            [self anialysisAssets:assets original:isOriginal];
////        }
//    }];
//
//    actionSheet.selectImageRequestErrorBlock = ^(NSArray<PHAsset *> * _Nonnull errorAssets, NSArray<NSNumber *> * _Nonnull errorIndex) {
//        NSLog(@"图片解析出错的索引为: %@, 对应assets为: %@", errorIndex, errorAssets);
//    };
//
//    actionSheet.cancleBlock = ^{
//        NSLog(@"取消选择图片");
//    };
//
//    return actionSheet;
//}


 
@end
